
package Server;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import client.Login;

import com.mysql.jdbc.Connection;
import com.mysql.jdbc.PreparedStatement;
import java.sql.*;
import ocsf.server.AbstractServer;
import ocsf.server.ConnectionToClient;

public class  Getuserid {
	
	/*
	 * 
	 * @author Ariel
	 * @param con1 Connection to the database
	 * @param userid Array of String which old the name of user (userid[1]) of witch we want to see his details 
	 * @return  Array of String => result  result[1]= Name, result[2]=Last name, result[3]= address
	 * 
	 * 
	 * 
	 * 
	 */

	
	public static String[] getuserdet(Connection con1,String[] userid )
	{
		String[] result = new String[5];
		
		
		 try
         {
             Statement stmt = con1.createStatement();
           
            
             
           
             ResultSet res = stmt.executeQuery("SELECT Name,Last_name,Address FROM clients WHERE User_name='"
						+ userid[1] + "'");
             
             
             
             
             if (res.next()) {
            	
  				  				
     			result[0]="1";
     			result[1]=res.getString(1);
     			result[2]=res.getString(2);
     			result[3]=res.getString(3);

     		} else     		
     			result[0]="2";

     		res.close();
     		
     	} catch (SQLException e) {
     		e.printStackTrace();
     	}
		
		
		return result;
		
	}

}
